package practice01;

public class practice01 {
    public static void main(String[] args) {
//        Sun s=new Sun("儿子");//1.父类静态代码块 2.父类构造代码块 3.父类无参构造
//        Father f=new Father();//4.父类构造代码块 5.父类无参构造
//        s.eat();//6.爸爸爱吃肉  7.父类局部代码块
//        s.play();//8..喜欢放风筝~
//        System.out.println(s.name);//儿子
//        Father.drink();
        Test test = new Test();

        test.method1();

        Test.method2(test);
    }
}
class Father {
        private  String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    static {
            System.out.println("父类静态代码块");
        }
    public Father() {
        System.out.println("父类无参构造");
    }
    public Father(String name) {
        this.name = name;
        System.out.println("父类含参构造");
        Father.drink();
    }
    {
        System.out.println("父类构造代码块");
    }
        public static void  drink(){
            System.out.println("喝水 静态方法");
            Father f=new Father();
            f.play();
    }
        public void eat () {
        System.out.println("爸爸爱吃肉");
            {
                System.out.println("父类局部代码块");
            }
    }
        public void play () {
        System.out.println("喜欢放风筝~");
    }
    }
class Sun extends Father  {
    String name;



    public Sun(String name) {
        this.name = name;
    }

    public Sun() {
    }
}
class Test {

    public void method1(){

        System.out.println("调用对象方法");

    }

    public static void method2(Test test){

        System.out.println("调用类方法");

        test.method1();//利用传参数的方法调用对象方法

        //为什么/this.method1();   会报错

        Test t=new Test();
        t.method1();
// 能解释一下this 吗？

    }


}
